var dbConfig = require('../util/dbconfig')

// 网站访问次数
insertVisit = (req, res) => {
    var { visit_num ,id} = req.query
    console.log(req.query)
    // console.log(req.body)
    var sql = `update visit set visit_num = '${visit_num}' where id = '${id}'`;
    console.log(sql)
    var sqlArr = [visit_num,id];
    var callBack = (err, data) => {
        if (err) {
            res.send({
                code: 400,
                msg: '修改失败',
            })
            console.log(err)
        } else {
            res.send({
                code: 200,
                msg: '修改成功',
            })
        }
    }
    dbConfig.sqlConnect(sql, sqlArr, callBack);
}
// 网站访问次数
getVisit = (req, res) => {
    var sql = `select visit_num from visit where id = 1`;
    console.log(sql)
    var sqlArr = [];
    var callBack = (err, data) => {
        if (err) {
            res.send({
                code: 400,
                msg: '查询失败',
            })
            console.log(err)
        } else {
            res.send({
                code: 200,
                msg: '查询成功',
                data

            })
        }
    }
    dbConfig.sqlConnect(sql, sqlArr, callBack);
}
module.exports = {
    insertVisit,
    getVisit
}